home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Grafik / Misc / ImageEnginer / ARexx / Adjust.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1999-09-18  |  3.4 KB  |  151 lines

  1. /*
  2. ** $VER: Adjust 1.21, IE Arexx script
  3. ** Image Engineer Macro script
  4. ** Copyright © by Patrik M Nydensten
  5. ** 15/1 1997 Stockholm/Sweden
  6. **
  7. ** Support for saving last used results added by MS
  8. **
  9. ** Adjust slices in image vertically or horizontally.
  10. */
  11.  
  12. Options results
  13. signal on error
  14.  
  15. NL = "0a"x
  16.  
  17. if arg()==0 then exit
  18. pic=arg(1)
  19.  
  20. PROJECT_INFO pic WIDTH
  21. picwidth=result
  22. PROJECT_INFO pic HEIGHT
  23. picheight=result
  24. PROJECT_INFO pic ZOOM
  25. origzoomval=result
  26.  
  27.  
  28. /* Get info from user */
  29.  
  30. if exists("ie:prefs/veadjust.cfg") == "1" then
  31.   do
  32.     call open("temp","ie:prefs/veadjust.cfg","R")
  33.     values=readln("temp")
  34.     parse var values ok dir adjh swidth adjv sheight .
  35.     call close("temp")
  36.   end
  37. else
  38.   do
  39.     dir=0
  40.     adjh=10
  41.     swidth=20
  42.     adjv=10
  43.     sheight=20
  44.   end
  45.  
  46.  
  47. 'FORM "Adjust" "Ok|Cancel"',
  48. 'RADIO,"Direction","Horizontally (Up & Down)|Vertically (Left & Right)|Both (First Horiz. then Vert.)|Both (First Vert. then Horiz.)",'dir'',
  49. 'INTEGER,"Slice adjustment (Horiz)",1,'picheight','adjh',SLIDER',
  50. 'INTEGER,"Slice width (Horiz)",1,'trunc(picwidth/2)','swidth',SLIDER',
  51. 'INTEGER,"Slice adjustment (Vert)",1,'picwidth','adjv',SLIDER',
  52. 'INTEGER,"Slice width (Vert)",1,'trunc(picheight/2)','sheight',SLIDER'
  53.  
  54. values=result
  55. parse var values ok dir adjh swidth adjv sheight .
  56.  
  57. if ok = 0 then exit
  58.  
  59. call open("temp","ie:prefs/veadjust.cfg","W")
  60. res=writeln("temp",values)
  61. call close("temp")
  62.  
  63.  
  64.  
  65. /* Let's go */
  66.  
  67. 'BRIGHTNESS' pic '-255' 'INTENSITY'  /* Black image */
  68. if RC==5 then exit
  69. AdjImage = RESULT
  70.  
  71. OrgImage = pic
  72.  
  73. UoD = -1
  74.  
  75. if dir==0 then call horiz()
  76. if dir==1 then call vert()
  77. if dir==2 then call horiz()
  78. if dir==3 then call vert()
  79.  
  80. if (dir==2|dir==3) then do
  81.   OrgImage = AdjImage
  82.   'BRIGHTNESS' pic '-255' 'INTENSITY'  /* Black image */
  83.   AdjImage = Result
  84. end
  85.  
  86. if dir==2 then call vert()
  87. if dir==3 then call horiz()
  88.  
  89. if (dir==2|dir==3) then 'CLOSE' OrgImage
  90.  
  91. exit
  92.  
  93. horiz:
  94.   do X = 0 to (picwidth+swidth) by swidth
  95.  
  96.     BX = X ; BY = 0 ; BEX = (X+swidth-1) ; BEY = (picheight-1)
  97.     if X >= picwidth then leave
  98.     if (X+swidth) > (picwidth-1) then BEX = (picwidth-1)
  99.  
  100.     'CROP' OrgImage BX BY BEX BEY
  101.     CropImage=RESULT
  102.  
  103.     'MARK' CropImage 'PRIMARY'
  104.     'MARK' AdjImage 'SECONDARY'
  105.     'COMPOSITE' X (trunc(adjh/2)*UoD) 'MIX 100'
  106.     Out = RESULT ; 'CLOSE' AdjImage ; 'CLOSE' CropImage ; AdjImage = Out
  107.  
  108.     if UoD = 1 then UoD = -1
  109.     else UoD = 1
  110.   end
  111. return 'OK'
  112.  
  113. vert:
  114.   do Y = 0 to (picheight+sheight) by sheight
  115.  
  116.     BX = 0 ; BY = Y ; BEX = (picwidth-1) ; BEY = (Y+sheight-1)
  117.     if Y >= picheight then leave
  118.     if (Y+sheight) > (picheight-1) then BEY = (picheight-1)
  119.  
  120.     'CROP' OrgImage BX BY BEX BEY
  121.     CropImage=RESULT
  122.  
  123.     'MARK' CropImage 'PRIMARY'
  124.     'MARK' AdjImage 'SECONDARY'
  125.     'COMPOSITE' (trunc(adjv/2)*UoD) Y 'MIX 100'
  126.     Out = RESULT ; 'CLOSE' AdjImage ; 'CLOSE' CropImage ; AdjImage = Out
  127.  
  128.     if UoD == 1 then UoD = -1
  129.     else UoD = 1
  130.   end
  131. return 'OK'
  132.  
  133. /*******************************************************************/
  134. /* This is where control goes when an error code is returned by IE */
  135. /* It puts up a message saying what happened and on which line     */
  136. /*******************************************************************/
  137.  
  138. error:
  139. if RC=5 then do
  140.     IE_TO_FRONT
  141.     LAST_ERROR
  142.     'REQUEST "'||RESULT||'"'
  143.     exit
  144. end
  145. else do
  146.     IE_TO_FRONT
  147.     LAST_ERROR
  148.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' ' OK '
  149.     exit
  150. end
  151.